package com.zhuangyuan.cloud.web.controller.api;

import com.zhuangyuan.cloud.data.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class CategoryApiController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/category/{name}/check")
    public boolean checkCategoryExists(@PathVariable("name")String name) throws Exception {
        Map<String,Object> map = new HashMap<>();
        map.put("name",name);
        boolean exists = false;
        exists = categoryService.exists(map);
        return exists;
    }

    @GetMapping("/category/{cateId}/cate_category")
    public Map getCateCategory(@PathVariable("cateId")String cateId){
        Map<String,String> map = new HashMap<>();
        map.put("parentId","");
        map.put("childId","");
        return map;
    }
}
